package com.cloudservice.ccs.biz.impl;

import com.cloudservice.ccs.biz.ITagsBiz;
import com.cloudservice.ccs.entity.Tags;
import com.cloudservice.ccs.exception.RoleManageException;
import com.cloudservice.ccs.exception.TagsException;
import com.cloudservice.ccs.mapper.TagsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TagsImpl implements ITagsBiz {
	@Autowired
	TagsMapper tagsMapper;

	@Override
	public void save(Tags tags) {
		int result = tagsMapper.save(tags);
		if (result == 0) {
			throw new TagsException("Create Tags entity error");
		}
	}

	@Override
	public void update(Integer id, Tags tags) {
		int result = tagsMapper.update(id, tags);
		if (result == 0) {
			throw new TagsException("Update Tags entity error");
		}
	}

	@Override
	public void partialUpdate(Integer id, Map<String, Object> fields) {
		int result = tagsMapper.partialUpdate(id, fields);
		if (result == 0) {
			throw new TagsException("Partial update Tags failed");
		}
	}

	@Override
	public void delete(Integer id) {
		int result = tagsMapper.delete(id);
		if (result == 0) {
			throw new TagsException("Delete Tags entity error");
		}
	}

	@Override
	public Tags getOne(Integer id) {
		Tags tags = tagsMapper.getOne(id);
		if (tags == null) {
			throw new TagsException("Get Tags entity error: no such entity");
		}
		return tags;
	}

	@Override
	public List<Tags> getAll() {
		return tagsMapper.getAll();
	}
}
